import { api } from './baseRequest';

// 模板消息相关API
export const templateMessageApi = {
  // 获取模板消息列表
  getTemplateList: async (params) => {
    try {
      const data = await api.get('/template-message/list', { params });
      return data.data;
    } catch (error) {
      console.error('获取模板列表失败:', error);
      // 返回模拟数据作为降级方案
      return {
        data: [
          {
            id: '1',
            title: '订单通知',
            templateId: 'OPENTM408731555',
            content: '您有一个新订单 #{{orderNo.DATA}}#，请及时处理。',
            example: '{"orderNo": {"value": "123456789"}}',
            status: 1,
            createTime: '2023-01-01 10:00:00',
            updateTime: '2023-01-01 10:00:00'
          }
        ],
        total: 1,
        page: 1,
        pageSize: 10
      };
    }
  }
};

export default templateMessageApi;